<?php

class Soul_Template_Html_Grid_Foot_Sum extends Soul_Template_Html_Grid_Foot_Base {
	
	private $_field = '';

    public function __construct(){
        parent::__construct();
    }
    
    public function getField(){
    	return $this->_field;
    }
    
    public function setField($value){
    	$this->_field = $value;
    	return $this;
    }

    public function render(){
		$data = $this->getGrid()->getDataSource();
		reset($data);
		$result = 0;
		foreach($data as $row){
			$result += $row[$this->getField()];
		}
		return '<td '.$this->getAttributeHtml().'><span>'.$result.'</span></td>';
    }
}